def is_leap_year(year):
    if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0):
        return True
    return False
def day_of_year(year, month, day):
    days_in_month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
    if is_leap_year(year):
        days_in_month[1] = 29
    day_of_year = sum(days_in_month[:month - 1]) + day
    return day_of_year
def main():
    year = int(input())
    month = int(input())
    day = int(input())
    
    result = day_of_year(year, month, day)
    print(result)

if __name__ == "__main__":
    main()